SET(FLTK_HPP_SRC "")
SET(FLTK_CPP_SRC "")
FLTK_PARSE_FL_FILE(FLTK_HPP_SRC FLTK_CPP_SRC)

AUX_SOURCE_DIRECTORY(. SERVER_SRC)
ADD_EXECUTABLE(server ${SERVER_SRC} ${FLTK_CPP_SRC})
ADD_DEPENDENCIES(server mir2x_3rds)

TARGET_INCLUDE_DIRECTORIES(server PRIVATE ${MIR2X_COMMON_SOURCE_DIR})
TARGET_INCLUDE_DIRECTORIES(server PRIVATE ${CMAKE_CURRENT_BINARY_DIR})
TARGET_INCLUDE_DIRECTORIES(server PRIVATE ${CMAKE_CURRENT_LIST_DIR})

TARGET_LINK_LIBRARIES(server common                )
TARGET_LINK_LIBRARIES(server ${TINYAES_LIBRARIES}  )
TARGET_LINK_LIBRARIES(server ${TINYXML2_LIBRARIES} )
TARGET_LINK_LIBRARIES(server ${LUA_LIBRARIES}      )
TARGET_LINK_LIBRARIES(server ${FLTK_LIBRARIES}     )
TARGET_LINK_LIBRARIES(server sqlite3               )
TARGET_LINK_LIBRARIES(server ${SQLITECPP_LIBRARIES})
TARGET_LINK_LIBRARIES(server ${CMAKE_DL_LIBS}      )
TARGET_LINK_LIBRARIES(server ${G3LOG_LIBRARIES}    )
TARGET_LINK_LIBRARIES(server ${LZ4_LIBRARIES}      )
TARGET_LINK_LIBRARIES(server ${ZSTD_LIBRARIES}     )
TARGET_LINK_LIBRARIES(server Threads::Threads      )

IF(WIN32 AND MSVC)
    MESSAGE(STATUS "Use windows native fiber library")
ELSE()
    TARGET_LINK_LIBRARIES(server ${ACO_LIBRARIES})
ENDIF()

INSTALL(TARGETS server DESTINATION server)
INSTALL(DIRECTORY ${CMAKE_SOURCE_DIR}/server/script DESTINATION server)
INSTALL(DIRECTORY ${MIR2X_DATA_REPO_PATH}/res/map DESTINATION server)
